package com.xbell.app.sys.postprocesser;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.stereotype.Component;

import com.xbell.app.sys.service.ZzglService;

@Component
public class BeanDefinitionPostProcessor implements BeanDefinitionRegistryPostProcessor{

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		((DefaultListableBeanFactory)beanFactory).setAllowBeanDefinitionOverriding(true);
		
	}

	@Override
	public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
		BeanDefinition bd = registry.getBeanDefinition("zzglService");
		if(bd!=null) {
			System.out.println("-------------");
		}
		((DefaultListableBeanFactory)registry).setAllowBeanDefinitionOverriding(true);
		BeanDefinitionBuilder bDB = BeanDefinitionBuilder.genericBeanDefinition(ZzglService.class);//new BeanDefinitionBuilder(ZzglService.class);
		registry.registerBeanDefinition("zzglService", bDB.getBeanDefinition());
		
		
	}

}
